<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head th:include="common/admin/adminHeader::html('编辑属性')" ></head>
<body>
<div th:replace="common/admin/adminNavigator::html" ></div>
<script>
    $(function(){
        var data4Vue = {
            uri: 'property',
            listURL:'listProperty',
            property: { id: 0, cid: 0, name: ''},
        };

        //ViewModel
        var vue = new Vue({
            el: '#workingArea',
            data: data4Vue,
            mounted:function(){ //mounted　表示这个 Vue 对象加载成功了
                this.get();
            },
            methods: {
                get:function(){
                    var id = getUrlParms("id");
                    var url = this.uri+"/"+id;
                    axios.get(url).then(function(response) {
                        vue.property = response.data.data;
                    })
                },
                update:function () {
                    if(!checkEmpty(this.property.name, "分类名称"))
                        return;
                    var url = this.uri+"/"+this.property.id;
                    axios.put(url,vue.property).then(function(response){
                        location.href=vue.listURL + "?cid=" + vue.property.cid;
                    });
                }
            }
        });
    });
</script>

<div id="workingArea">

    <ol class="breadcrumb">
        <li><a :href="'listProperty?cid=' + property.cid">所有属性</a></li>
        <li class="active">编辑分类</li>
    </ol>

    <div class="panel panel-warning editDiv">
        <div class="panel-heading">编辑分类</div>
        <div class="panel-body">
            <table class="editTable">
                <tr>
                    <td>分类名称</td>
                    <td><input  @keyup.enter="update" v-model.trim="property.name" type="text" class="form-control"></td>
                </tr>
                <tr class="submitTR">
                    <td colspan="2" align="center">
                        <input type="hidden" name="id"   v-model.trim="property.id" >
                        <a href="#nowhere" class="btn btn-success" @click="update">提 交</a>
                    </td>
                </tr>
            </table>
        </div>
    </div>
</div>

<div th:replace="common/admin/adminFooter::html" ></div>
</body>
</html>






